<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>鑫多多</title>
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<script src="../js/angular/angular.min.js"></script>
		<script src="../js/angular/angular-resource.js"></script>
		<script src="../js/angular/common.js"></script>
		<script src="../js/mui.min.js"></script>
		<script src="../js/common.js"></script>
		<script src="../js/service/goodsService.js"></script>
		<script src="../js/mui.pullToRefresh.js"></script>
		<script src="../js/mui.pullToRefresh.material.js"></script>
		<link rel="stylesheet" href="../css/mui.min.css">
		<link href="../css/icons-extra.css" rel="stylesheet" />
		<link href="../css/iconfont.css" rel="stylesheet" />
		<link href="../css/style.css" rel="stylesheet" />

	</head>

	<body ng-app="mainApp" ng-controller="evaAllCtrl">

		<header class="mui-bar mui-bar-nav mui-bar-detail">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">产品评价</h1>
		</header>
		<nav class="mui-bar mui-bar-tab pro_bar">
			<a class="mui-tab-item mui-col-xs-2">
				<span class="mui-icon mui-icon-extra mui-icon-extra-custom" ng-click="myCustomService()"></span>
				<span class="mui-tab-label">客服</span>
			</a>
			<a class="mui-tab-item mui-col-xs-2" ng-click="myShopCart()">
				<span class="mui-icon mui-icon-extra mui-icon-extra-cart"></span>
				<span class="mui-tab-label">购物车</span>
			</a>
			<a class="mui-tab-item mui-btn mui-btn-warning mui-col-xs-4" href="#specification">

				<span class="mui-tab-label">加入购物车</span>
			</a>
		</nav>
		<div id="specification" class="mui-popover mui-popover-action mui-popover-bottom specification" style="display: none;">

			<div class="mui-table-view mui-media spe_top">
				<a href="#specification"><i class="mui-icon mui-icon-close mui-pull-right"></i></a>
				<div class="mui-pull-left media-object-wrap"> 
					<img ng-if="ifPic" class="mui-media-object" ng-src="{{baseUrl}}/dapi/download/getImageIO?imgUrl={{iconUrl}}"></img>
					<img ng-if="!ifPic" class="mui-media-object" ng-src="../images/goodsDefault.gif"></img>
				</div>
				<div class="mui-media-body price">
					¥{{gprice}}
					<p>已选{{goodsNum}}件</p>
				</div>

			</div>

			<div class="mui-content-padded mum_box_wrap">

				数量
				<div class="mui-numbox">
					<button  class="mui-btn mui-btn-numbox-minus" type="button"ng-disabled="goodsNum==0" >-</button>
					<input class="mui-input-numbox" type="number" ng-model="goodsNum">
					<button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
				</div>
			</div>
			<div class="spe_btn">
				<button type="button" class="mui-btn mui-btn-warning  mui-pull-left mui-col-xs-6" ng-click="shoppingCart()">加入购物车</button>
			</div>

		</div>
		<!-- 主页面内容容器 -->
		<div id="pullrefresh" class="mui-content mui-scroll-wrapper">
			<div class="mui-scroll">
				<ul class="mui-table-view mui-table-view-chevron">
					<li class="mui-table-view-cell" ng-repeat="eva in evaList">
						{{eva.content}}
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-10">
								<h5 class="mui-ellipsis">{{eva.publishUserName}}</h5>
								<p class="mui-h6 mui-ellipsis">{{eva.content}}</p>
							</div>
							<div class="mui-table-cell mui-col-xs-2 mui-text-right">
								<span class="mui-h5">{{eva.publishTime|timeStr}}</span>
							</div>
						</div>
					</li>
					
				</ul>
			</div>
		</div>
		<script>	
			mainApp.controller('evaAllCtrl', function($scope, $http,goodsService) {
				$scope.pageIndex=1;
				$scope.pageSize=5;
				$scope.baseUrl=baseUrl;
				mui.plusReady(function(){
					var se= plus.webview.currentWebview();
					$scope.goodsId=se.goodsId;
					$scope.iconUrl=se.iconUrl;
					$scope.ifPic=se.ifPic;
					$scope.gprice=se.gprice;
					$scope.goodsNum=se.goodsNum;
					var success_s=function(data){
						mui.alert("加入购物车成功！");
					}
					$scope.dzPageIndex=1;
					$scope.evaList;
					var getList=function(){
						//请求评价数据
						goodsService.getGoodsEvaluate($scope.goodsId,$scope.dzPageIndex,$scope.pageSize,function(data){
							if($scope.pageIndex==1){
								$scope.evaList=data.data.list;
							}else{
								angular.forEach(data.data.list, function(goods) {
									$scope.evaList.push(goods);
								});
							}
							$scope.dzPageIndex=$scope.dzPageIndex+1;
						},error) ;
					}
					//初始化列表数据
					getList();
					
					(function($) {
					//阻尼系数
						var deceleration = mui.os.ios?0.003:0.0009;
						$('.mui-scroll-wrapper').scroll({
							bounce: false,
							indicators: true, //是否显示滚动条
							deceleration:deceleration
						});
					});
					mui.init({ 
					swipeBack: false,
					pullRefresh: {
						container: '#pullrefresh',
						down : {
						      style:'circle',//必选，下拉刷新样式，目前支持原生5+ ‘circle’ 样式
						      color:'#2BD009', //可选，默认“#2BD009” 下拉刷新控件颜色
						      height:'50px',//可选,默认50px.下拉刷新控件的高度,
						      range:'100px', //可选 默认100px,控件可下拉拖拽的范围
						      offset:'0px', //可选 默认0px,下拉刷新控件的起始位置
						      auto: false,//可选,默认false.首次加载自动上拉刷新一次
						      callback :pulldownRefresh //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
						},
						up: {
							/*contentrefresh: '正在加载...',
							callback: pullupRefresh*/
						}
					}
				});
					/**
				 * 下拉刷新具体业务实现
				 */
				function pulldownRefresh() {
					setTimeout(function() {
						$scope.pageIndex=$scope.pageIndex+1;
						getList();
						mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed
					}, 1000);
				}
				});
				
				//加入购物车
				$scope.shoppingCart=function(){
					if($scope.goodsNum==0){
						mui.alert("请选择商品数量");
						return;
					}
					$scope.shopcart={"goodsId":$scope.goodsId ,"number":$scope.goodsNum};
					goodsService.addShopCart($scope.shopcart, success_s, error);
				}
				//查询我的购物车
				$scope.myShopCart=function(){
					mui.openWindow({
						url:'shoppingCart.html',
						id:'shoppingCart'+new Date().getMilliseconds(),
						show: {
							aniShow: 'pop-in'
						},
						waiting: {
							autoShow: false
						}
					});
				}
				//客服
				$scope.myCustomService=function(){
					mui.openWindow({
						url:'cusSerUser.html',
						id:'cusSerUser'+new Date().getMilliseconds(),
						preload: true,
						show: {
							aniShow: 'pop-in'
						},
						waiting: {
							autoShow: false
						},
						extras:{//参数传递
							/*goodsId:self.goodsId,
							iconUrl:$scope.goods.iconUrl,
							ifPic:$scope.goods.ifPic,
							gprice:$scope.goods.price,
							goodsNum:$scope.goodsNum*/
						}
					});
				}
			});
		</script>

</html>